pub test: bool,
pub doc: bool,
pub run_custom_build: bool,
+ pub panic: Option<String>,
}
#[derive(Default, Clone, Debug)]
pub release: Profile,
pub dev: Profile,
pub test: Profile,
+ pub test_deps: Profile,
pub bench: Profile,
+ pub bench_deps: Profile,
pub doc: Profile,
pub custom_build: Profile,
}
test: false,
doc: false,
run_custom_build: false,
+ panic: None,
}
}
}
try!(rm_rf(&layout.build(&pkg)));
let Profiles {
ref release, ref dev, ref test, ref bench, ref doc,
- ref custom_build,
+ ref custom_build, ref test_deps, ref bench_deps,
} = *root.manifest().profiles();
- for profile in [release, dev, test, bench, doc, custom_build].iter() {
+ let profiles = [release, dev, test, bench, doc, custom_build,
+ test_deps, bench_deps];
+ for profile in profiles.iter() {
let unit = Unit {
pkg: &pkg,
target: target,
let mut build_config = try!(scrape_build_config(config, jobs, target));
build_config.exec_engine = exec_engine.clone();
build_config.release = release;
+ build_config.test = mode == CompileMode::Test;
if let CompileMode::Doc { deps } = mode {
build_config.doc_all = deps;
}
}
pub fn lib_profile(&self, _pkg: &PackageId) -> &'a Profile {
- if self.build_config.release {
- &self.profiles.release
+ let (normal, test) = if self.build_config.release {
+ (&self.profiles.release, &self.profiles.bench_deps)
} else {
- &self.profiles.dev
+ (&self.profiles.dev, &self.profiles.test_deps)
+ };
+ if self.build_config.test {
+ test
+ } else {
+ normal
}
}
pub requested_target: Option<String>,
pub exec_engine: Option<Arc<Box<ExecEngine>>>,
pub release: bool,
+ pub test: bool,
pub doc_all: bool,
}
let Profile {
opt_level, lto, codegen_units, ref rustc_args, debuginfo,
debug_assertions, rpath, test, doc: _doc, run_custom_build,
- rustdoc_args: _,
+ ref panic, rustdoc_args: _,
} = *unit.profile;
assert!(!run_custom_build);
cmd.arg("-C").arg(&format!("opt-level={}", opt_level));
}
+ if let Some(panic) = panic.as_ref() {
+ cmd.arg("-C").arg(format!("panic={}", panic));
+ }
+
// Disable LTO for host builds as prefer_dynamic and it are mutually
// exclusive.
if unit.target.can_lto() && lto && !unit.target.for_host() {
debug: Option<bool>,
debug_assertions: Option<bool>,
rpath: Option<bool>,
+ panic: Option<String>,
}
#[derive(RustcDecodable)]
fn build_profiles(profiles: &Option<TomlProfiles>) -> Profiles {
let profiles = profiles.as_ref();
- return Profiles {
+ let mut profiles = Profiles {
release: merge(Profile::default_release(),
profiles.and_then(|p| p.release.as_ref())),
dev: merge(Profile::default_dev(),
profiles.and_then(|p| p.dev.as_ref())),
test: merge(Profile::default_test(),
profiles.and_then(|p| p.test.as_ref())),
+ test_deps: merge(Profile::default_dev(),
+ profiles.and_then(|p| p.dev.as_ref())),
bench: merge(Profile::default_bench(),
profiles.and_then(|p| p.bench.as_ref())),
+ bench_deps: merge(Profile::default_release(),
+ profiles.and_then(|p| p.release.as_ref())),
doc: merge(Profile::default_doc(),
profiles.and_then(|p| p.doc.as_ref())),
custom_build: Profile::default_custom_build(),
};
+ profiles.test_deps.panic = None;
+ profiles.bench_deps.panic = None;
+ return profiles;
fn merge(profile: Profile, toml: Option<&TomlProfile>) -> Profile {
let &TomlProfile {
- opt_level, lto, codegen_units, debug, debug_assertions, rpath
+ opt_level, lto, codegen_units, debug, debug_assertions, rpath,
+ ref panic
} = match toml {
Some(toml) => toml,
None => return profile,
test: profile.test,
doc: profile.doc,
run_custom_build: profile.run_custom_build,
+ panic: panic.clone().or(profile.panic),
}
}
}
assert_that(p.cargo_process("build").arg("-v"),
execs().with_status(0));
});
+
+test!(panic_abort_compiles_with_panic_abort {
+ if !::is_nightly() {
+ return
+ }
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ authors = []
+
+ [profile.dev]
+ panic = 'abort'
+ "#)
+ .file("src/lib.rs", "");
+ assert_that(p.cargo_process("build").arg("-v"),
+ execs().with_status(0)
+ .with_stderr_contains("[..] -C panic=abort [..]"));
+});
"));
});
+test!(test_panic_abort_with_dep {
+ if !::is_nightly() {
+ return
+ }
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ authors = []
+
+ [dependencies]
+ bar = { path = "bar" }
+
+ [profile.dev]
+ panic = 'abort'
+ "#)
+ .file("src/lib.rs", r#"
+ extern crate bar;
+
+ #[test]
+ fn foo() {}
+ "#)
+ .file("bar/Cargo.toml", r#"
+ [package]
+ name = "bar"
+ version = "0.0.1"
+ authors = []
+ "#)
+ .file("bar/src/lib.rs", "");
+ assert_that(p.cargo_process("test").arg("-v"),
+ execs().with_status(0));
+});